package com.sdp.lease;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import com.sdp.core.bizc.utils.ApplicationContextUtils;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@EnableTransactionManagement
@SpringBootApplication(scanBasePackages = "com.sdp")
public class LeaseWeiXinApplication {

	public static void main(String[] args) throws UnknownHostException {
		try {
			SpringApplication springApplication = new SpringApplication(LeaseWeiXinApplication.class);
			springApplication.addInitializers(new ApplicationContextUtils());
			ConfigurableApplicationContext applition = springApplication.run(args);
			ConfigurableEnvironment env = applition.getEnvironment();
			String ip = InetAddress.getLocalHost().getHostAddress();
			String port = env.getProperty("server.port");
			String path = env.getProperty("server.servlet.context-path");
			log.info("\n----------------------------------------------------------\n\t" +
						"Application right-cloud is running! Access URLs:\n\t" +
						"Local: \t\thttp://localhost:" + port + path + "\n\t" +
						"External: \thttp://" + ip + ":" + port + path + "\n" +
						"----------------------------------------------------------");
		}catch (Throwable e){
			e.printStackTrace();
		}
	}
}
